package com.xuecheng.orders.feignclient;

import com.xuecheng.orders.model.dto.CourseAndCategoryDto;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author itcast
 */
@Slf4j
@Component
public class ContentServiceClientFallbackFactory implements FallbackFactory<ContentServiceClient> {
    @Override
    public ContentServiceClient create(Throwable throwable) {
        return new ContentServiceClient() {
            @Override
            public CourseAndCategoryDto getCategory(Long id) {
                log.error("查询课程分类信息发生熔断，课程id：{}，异常信息：{}", id, throwable.toString(), throwable);
                return null;
            }
        };
    }
}
